import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from "vue-router";

let Layout = () => import("@/layout/Layout.vue");
/**
 * meta:
 *    hidden:true,          隐藏该路由菜单
 *    icon:""               icon
 *    keepAlive:true        该路由将被缓存
 *    title                 菜单名称
 */
// 静态路由
const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "登录",
    meta: {
      title: "登录页",
      hidden: true,
      noTabbarShow: true,
    },
    component: () => import("@/views/login/Login.vue"),
  },
];
// 动态路由
export const dynamicRoutes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Dashboard",
    component: Layout,
    redirect: { path: "/table/basic" },
    meta: {
      hidden: true,
      title: "首页",
      noTabbarShow: true,
    },
    children: [],
  },
];
// 后期接入菜单服务时可以去掉
const remoteRoutes: Array<RouteRecordRaw> = [
  {
    path: "/table",
    name: "TableBasic",
    redirect: { path: "/table/basic" },
    component: Layout,
    meta: {
      icon: "Grid",
      title: "表格",
    },
    children: [
      {
        path: "/table/basic",
        name: "TableBasic",
        component: () => import("@/views/demo/table/TableBasic.vue"),
        meta: {
          icon: "Grid",
          title: "基础表格",
          alwaysShow: true,
          tabbarDisplay: "inherit",
        },
      },
    ],
  },
  {
    path: "/form",
    component: Layout,
    redirect: { path: "/form/basic" },
    meta: {
      icon: "Document",
      title: "表单",
    },
    children: [
      {
        path: "/form/basic",
        name: "FormBasic",
        component: () => import("@/views/demo/form/FormBasic.vue"),
        meta: {
          title: "基础表单",
          keepAlive: true,
          tabbarDisplay: "inherit",
        },
      },
      {
        path: "/form/query",
        name: "FormQuery",
        component: () => import("@/views/demo/form/FormQuery.vue"),
        meta: {
          title: "查询表单",
          tabbarDisplay: "inherit",
        },
      },
    ],
  },
  {
    path: "/tabbar",
    component: Layout,
    redirect: { path: "/tabbar/basic" },
    meta: {
      icon: "Document",
      title: "tabbar基础",
      tabbarDisplay: "inherit",
    },
    children: [
      {
        path: "/tabbar/basic",
        name: "TabbarBasic",
        component: () => import("@/views/demo/tabbar/TabbarBasic.vue"),
        meta: {
          icon: "Document",
          title: "基础Tabbar",
          alwaysShow: true,
          tabbarDisplay: "inherit",
        },
      },
    ],
  },
  {
    path: "/test",
    component: Layout,
    meta: {
      icon: "Document",
      title: "test测试路由模块",
    },
    children: [
      {
        path: "/test/index1",
        name: "index1",
        component: () => import("@/views/demo/test/index1.vue"),
        meta: {
          title: "岁的法国色如果物色个人",
        },
      },
      {
        path: "/test/index2",
        name: "index2",
        component: () => import("@/views/demo/test/index2.vue"),
        meta: {
          title: "岁的法国serge人格",
        },
      },
      {
        path: "/test/index3",
        name: "index3",
        component: () => import("@/views/demo/test/index3.vue"),
        meta: {
          title: "士大夫敢死队割让给色弱",
        },
      },
      {
        path: "/test/index4",
        name: "index4",
        component: () => import("@/views/demo/test/index4.vue"),
        meta: {
          title: "阿嘎尔瓦图var二日",
        },
      },
      {
        path: "/test/index5",
        name: "index5",
        component: () => import("@/views/demo/test/index5.vue"),
        meta: {
          title: "阿文v波特率她她她",
        },
      },
      // 新增

      {
        path: "/test/index6",
        name: "index6",
        component: () => import("@/views/demo/test/index6.vue"),
        meta: {
          title: "撒各色然后让他那样容易内容",
        },
      },
      {
        path: "/test/index7",
        name: "index7",
        component: () => import("@/views/demo/test/index7.vue"),
        meta: {
          title: "和个人委任他为v本文",
        },
      },
      {
        path: "/test/index8",
        name: "index8",
        component: () => import("@/views/demo/test/index8.vue"),
        meta: {
          title: "三个人为一百",
        },
      },
      {
        path: "/test/index9",
        name: "index9",
        component: () => import("@/views/demo/test/index9.vue"),
        meta: {
          title: "为个人个人个人",
        },
      },
      {
        path: "/test/index10",
        name: "index10",
        component: () => import("@/views/demo/test/index10.vue"),
        meta: {
          title: "奥斯鉴定费奥i",
        },
      },
    ],
  },
];
// 后期接入菜单服务时可以去掉
dynamicRoutes?.push(...remoteRoutes);
// for (let i = 0; i < 4; i++) {
//   dynamicRoutes.children?.push(...remoteRoutes);
// }
const router = createRouter({
  history: createWebHashHistory("/lsgfish-admin"),
  routes: [...constantRoutes, ...dynamicRoutes],
});
export default router;
